package com.jb.security;

import com.jb.faces.context.FacesContext;
import com.jb.web.session.SessionUser;


public interface SecurityManager extends Authenticator {
    /**
     * Initializes this manager. This method is called to initialized
     * the security manager. In this method, implementor should implement
     * logic for setting up the security system including data
     * store, key store etc required for the manager to work.
     * @param ctx runtime context.
     */
    public void initialize(FacesContext ctx);
    /**
     * Returns previlige a user on a resource. 
     * @param ctx runtime context.
     * @param visitor the user 
     * @param resource the resource to access
     * @return 
     */
    public int authorize(FacesContext ctx, SessionUser visitor, Object resource);
    
    /**
     * Create a guest user
     * @return guest user
     */
    public SessionUser createGuestUser();
    /**
     * Create a user.
     * @param ctx runtime context.
     * @param userName the username for the new user.
     * @param password the password for the new user.
     * @return the user created, or null. 
     */
     public SessionUser createUser(FacesContext ctx, String userName, String password);
   
    /**
     * Updates a user details.
     * @param ctx runtime context.
     * @param user the user to be updated.
     */
    public void updateUser(FacesContext ctx, SessionUser user);
    /**
     * Find a user by user name.
     * @param userName
     * @return the user found, or null.
     */
    public SessionUser findUser(FacesContext ctx, String userName);

}
